﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Fast.RemoteRequest
{
    public interface IHttpRemoteRequest
    {
        /// <summary>
        /// 设置请求Url
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetRequestUrl(string url);

        /// <summary>
        /// 设置客户端分类名
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetClientName(string name);

        /// <summary>
        /// 设置超时时间（秒）
        /// </summary>
        /// <param name="timeout"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetClientTimeout(TimeSpan timeout);

        /// <summary>
        /// 设置超时时间（秒）
        /// </summary>
        /// <param name="timeout"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetClientTimeout(long timeout);

        /// <summary>
        /// 设置重试次数
        /// </summary>
        /// <param name="retryCount"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetRetryCount(int retryCount);

        /// <summary>
        /// 设置 URL 参数
        /// </summary>
        /// <param name="queryParams"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetQueryParams(IDictionary<string, object> queryParams);

        /// <summary>
        /// 设置 URL 参数
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetQueryParams(string key, object value);

        /// <summary>
        /// 设置 Authorization
        /// </summary>
        /// <param name="type"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetAuthorization(AuthorizationType type, object value);

        /// <summary>
        /// 设置请求头
        /// </summary>
        /// <param name="headers"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetHeaders(IDictionary<string, object> headers);

        /// <summary>
        /// 设置请求头
        /// </summary>
        /// <param name="headers"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetHeaders(string key, object value);

        /// <summary>
        /// 设置请求头
        /// </summary>
        /// <param name="headers"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetBody(object body, string contentType = default, Encoding encoding = default);

        /// <summary>
        /// 设置 Body  Bytes
        /// </summary>
        /// <param name="bytesData"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetBodyBytes(params (string Name, byte[] Bytes, string FileName)[] bytesData);

        /// <summary>
        /// 设置内容类型
        /// </summary>
        /// <param name="contentType"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetContentType(string contentType);

        /// <summary>
        /// 设置内容编码
        /// </summary>
        /// <param name="encoding"></param>
        /// <returns></returns>
        IHttpRemoteRequest SetContentEncoding(Encoding encoding);

        /// <summary>
        /// 发送请求返回 HttpResponseMessage 对象
        /// </summary>
        /// <param name="httpMethod"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<HttpResponseMessage> SendAsync(HttpMethod httpMethod, CancellationToken cancellationToken = default);
    }
}
